<template>
  <div class="textbook">
    <!-- ////顶部搜索栏 -->
    <div class="top-search">
      <div class="content">
        <div class="top-right_d">
          <img src="../../assets/dbw-image/pdf_icon.png" alt />
          <h4>PA教材大全</h4>
          <p>
            <a href="/">主页</a>
            »
            <a href>PA教材</a>
          </p>
        </div>
        <!-- 左侧跳动文字 -->
        <div class="word">
          <span class="one glyphicon glyphicon-volume-up" aria-hidden="true"></span>
          <ul>
            <li v-for="item in wordList" :key="item.id">
              <span>{{item.ti}}</span>
              <strong style="color:#ff0000" v-show="item.str">{{item.str}}</strong>
              <span v-show="item.wei">{{item.wei}}</span>
            </li>
          </ul>
        </div>

        <!-- 右侧搜索 -->
        <div class="search clearfix">
          <div
            class="input-group navbar-form navbar-right"
            style="width:200px;margin:0px;padding:5px;"
            role="search"
          >
            <input
              type="text"
              id="Keyword"
              name="keyword"
              required
              class="form-control input-sm"
              placeholder="搜索本站SAP资料"
            />
            <div class="input-group-btn">
              <input type="button" id="Search" class="btn btn-default btn-sm" value="Go!" />
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container_d">
      <div class="left_d">
        <a href class="f5" v-for="item in textList" :key="item.id">
          <i>{{item.textbook}}</i>
          <p>
            <span
              v-for="(item2,index2) in item.t_tag"
              :class="['label', cs(index2)]"
              :key="index2"
            >{{item2}}</span>
          </p>
        </a>
      </div>

      <div class="right_top_d">
        <div class="right_child_top">
          <span>
            <a href>
              <i>图书标签</i>
            </a>
          </span>
        </div>
        <div class="eBook-label">
          <span
            v-for="(item, index) in bookLabel"
            :key="index"
            :class="['pad', 'label', csLabel(index)]"
          >
            {{item.txt}}
            <span class="badge">{{item.num}}</span>
          </span>
        </div>
      </div>
      <div class="right_bottom_d">
        <div class="right_child_top">
          <span>
            <a href>
              <i>友情链接</i>
            </a>
          </span>
        </div>
        <div class="right_child_bottom_second">
          <a href>
            <img src="../../assets/dbw-image/lianjie_icon.png" alt />
            <p>JavaWeb开发者社区</p>
          </a>
        </div>
      </div>
    </div>
    <div
      class="footer"
      style="height:100px;background-color:#2e2e2e;margin-top:10px;font-size:14px"
    >
      本站所有电子书全部来自于互联网，欢迎大家给小编投稿+V:FICODK
      <p>
        © 2018 All Rights Reserved by SAPDOC.cn. |
        <a
          href="http://www.miitbeian.gov.cn/"
          style="color:#e5e5e5;font-size:14px"
        >沪ICP备17005776号-3</a>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      animate: false,
      textList: [],
      bookLabel: {},
      wordList: [
        {
          ti: "SAP文库全新改版，注册最多",
          str: "赠送400积分",
          wei: "用于购买各类资料！"
        },
        {
          ti: " 欢迎猎头和HR入住，",
          str: "免费发布SAP招聘信息！本站5个微信群同步免费推送！"
        },
        {
          ti:
            "本站所有内容均来自互联网用户分享，如有违规内容，纯属本站管理不善，请及时联系我们删除。"
        }
      ]
    };
  },
  methods: {
    showMarquee: function() {
      setTimeout(() => {
        this.wordList.push(this.wordList[0]);
        this.wordList.shift();
      }, 500);
    },
    cs(num) {
      num = num % 6;
      switch (num) {
        case 0:
          return "label-default";
        case 1:
          return "label-primary";
        case 2:
          return "label-success";
        case 3:
          return "label-info";
        case 4:
          return "label-warning";
        case 5:
          return "label-danger";
      }
    },
    async getTextList() {
      const { data: res } = await this.$axios.get("/textbook");
      this.textList = res.data;

      this.textList.forEach(item => {
        item.t_tag = item.t_tag.split(",");
      });
      // console.log(this.textList);
    },
    // 彩色标签
    csLabel(n) {
      n = n % 6;
      switch (n) {
        case 0:
          return "label-default";
        case 1:
          return "label-primary";
        case 2:
          return "label-success";
        case 3:
          return "label-info";
        case 4:
          return "label-warning";
        case 5:
          return "label-danger";
      }
    },
    // 获取数据
    async getGod() {
      const { data: res } = await this.$axios.get("/eLabel");
      this.bookLabel = res.data.list;
      // console.log(res);
    }
  },
  created() {
    setInterval(this.showMarquee, 2000);
    this.getTextList();
    this.getGod();
  }
};
</script>

<style lang="less" scoped>
.textbook {
  background-color: #fcf8e3;
}
.top_d {
  border: 1px solid #ddd;
  height: 70px;
  background-color: white;
}
.top-right_d {
  display: inline-block;
  float: left;
}
.top-right_d > h4 {
  display: inline-block;
  margin-top: 15px;
  font-weight: bold;
  font-size: 18px;
  color: #555;
  margin-left: 5px;
}
.top-right_d img {
  width: 25px;
  height: 25px;
  margin-top: -13px;
}
.top-right_d a {
  text-decoration: none;
  color: #333;
  font-size: 13px;
}
.top-search {
  width: 100%;
  height: 80px;
  background-color: #fff;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}
.content {
  width: 1150px;
  /* height: 100%; */
  margin: 0 auto;
}

.word {
  float: left;
  color: #808080;
  height: 20px;
  overflow: hidden;
  margin-top: 15px;
  margin-left: 82px;
}
span.one {
  color: #428bca;
  float: left;
  margin-right: 35px;
}
.word ul {
  float: left;
}

.word li {
  background-color: #fff;
}

.marquee_top {
  transition: all 0.1s;
  margin-top: -30px;
}
.search {
  position: relative;
  top: 5px;
  float: right;
}

.container_d {
  width: 1140px;
  height: 1800px;
  padding: 15px;
  margin-right: auto;
  margin-left: auto;
  position: relative;
}
.container_d > div {
  background-color: white;
  border: 1px solid #ddd;
  display: inline-block;
  border-radius: 4px;
}
.left_d {
  width: 820px;
  /* height: 1726px; */
}
.left_d > a {
  display: inline-block;
  width: 100%;
  border-bottom: 1px solid #ddd;
  height: 75px;
  padding: 10px 15px;
}
.f5:hover {
  background-color: #f5f5f5;
}
.container_d i {
  color: #333;
  font-weight: bold;
  font-size: 15px;
  font-family: inherit;
}
.container_d a {
  color: black;
  text-decoration: none;
}
.left_d > a span {
  display: inline-block;
  margin-right: 3px;
  font-size: 12px;
  font-weight: 100;
  margin-bottom: 2px;
  padding: 4px;
}
.right_top_d {
  width: 275px;
  padding: 10px 10px;
  margin-left: 10px;
  // position: relative;
  // top: -1670px;
  // right: 0px;
  position: absolute;
  top: 15px;
  right: 0;
  box-sizing: border-box;
}
.right_bottom_d {
  width: 275px;
  height: 90px;
  // position: relative;
  // bottom: 1979px;
  // left: 830px;
  position: absolute;
  top: 167px;
  right: 0px;
  margin-top: 315px;
}
.right_bottom_d {
  padding: 10px;
}
.right_child_top {
  padding: 0px 10px 10px 10px;
  border-bottom: 1px solid #ddd;
}
.right_child_top span {
  padding-bottom: 11px;
  margin-bottom: -10px;
  border-bottom-color: #f98181;
  border-bottom-style: solid;
  border-bottom-width: 2px;
}
.right_child_bottom_second {
  margin-top: 10px;
}
.right_child_bottom_second p {
  display: inline-block;
}
.right_child_bottom_second img {
  width: 25px;
  height: 25px;
}
.footer {
  width: 100%;
  padding-top: 30px;
  text-align: center;
  color: #999999;
}

/******** 图书标签 */
.eBook-label {
  width: 100%;
  height: 100%;
  padding-left: 5px;

  span.pad {
    display: inline-block;
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: 400;
    margin-right: 3px;
  }

  span.badge {
    display: inline-block;
    min-width: 8px;
    padding: 2px 5px;
    font-size: 10px;
    font-weight: bold;
    color: #808080;
    line-height: 1;
    vertical-align: middle;
    white-space: nowrap;
    text-align: center;
    background-color: #fff;
    border-radius: 10px;
  }
}
</style>